﻿using System;
using System.Collections.Generic;

using SharedGenomics.Annotations;

namespace SharedGenomics.Workbench.Annotations
{
    public class AnnotationKeyDependencyGraphProvider
    {
        private static readonly AnnotationKeyDependencyGraph _requestGraph;
        private static readonly AnnotationKeyDependencyGraph _annotationGraph;

        static AnnotationKeyDependencyGraphProvider()
        {
            _requestGraph = CreateRequestGraph();
            _annotationGraph = CreateAnnotationGraph();
        }

        public virtual AnnotationKeyDependencyGraph GetRequestDependencyGraph()
        {
            return _requestGraph;
        }

        public virtual AnnotationKeyDependencyGraph GetAnnotationDependencyGraph()
        {
            return _annotationGraph;
        }

        private static AnnotationKeyDependencyGraph CreateRequestGraph()
        {
            var dependencyEdges = new List<AnnotationKeyDependencyEdge>
            {
                new AnnotationKeyDependencyEdge(AnnotationKey.SnpName, AnnotationKey.GoogleSearch),
                new AnnotationKeyDependencyEdge(AnnotationKey.SnpName, AnnotationKey.NcbiSummary),
                new AnnotationKeyDependencyEdge(AnnotationKey.NcbiSummary, AnnotationKey.Publications),
                new AnnotationKeyDependencyEdge(AnnotationKey.NcbiSummary, AnnotationKey.PubMedSearch),
                new AnnotationKeyDependencyEdge(AnnotationKey.NcbiSummary, AnnotationKey.KeggPathway),
                new AnnotationKeyDependencyEdge(AnnotationKey.NcbiSummary, AnnotationKey.Gene),
                new AnnotationKeyDependencyEdge(AnnotationKey.NcbiSummary, AnnotationKey.KeggId)
            };

            return new AnnotationKeyDependencyGraph(dependencyEdges);
        }

        private static AnnotationKeyDependencyGraph CreateAnnotationGraph()
        {
            var dependencyEdges = new List<AnnotationKeyDependencyEdge>
            {
                new AnnotationKeyDependencyEdge(AnnotationKey.SnpName, AnnotationKey.GoogleSearch),
                new AnnotationKeyDependencyEdge(AnnotationKey.SnpName, AnnotationKey.NcbiSummary),
                new AnnotationKeyDependencyEdge(AnnotationKey.SnpName, AnnotationKey.EntrezGeneId),
                new AnnotationKeyDependencyEdge(AnnotationKey.EntrezGeneId, AnnotationKey.Publications),
                new AnnotationKeyDependencyEdge(AnnotationKey.EntrezGeneId, AnnotationKey.PubMedSearch),
                new AnnotationKeyDependencyEdge(AnnotationKey.EntrezGeneId, AnnotationKey.Gene),
                new AnnotationKeyDependencyEdge(AnnotationKey.EntrezGeneId, AnnotationKey.KeggId),
                new AnnotationKeyDependencyEdge(AnnotationKey.EntrezGeneId, AnnotationKey.KeggPathway),
            };

            return new AnnotationKeyDependencyGraph(dependencyEdges);
        }
    }
}